package org.rebluh.hulunbuirtravelnetworkbackendframework.service;

import org.rebluh.hulunbuirtravelnetworkbackendframework.domain.Image;
import org.rebluh.hulunbuirtravelnetworkbackendframework.repository.ImageRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class ImageService {
    @Autowired
    private ImageRepository imageRepository;

    //添加图片
    public Image createImage(Image image) {
        return imageRepository.save(image);
    }

    //根据hulber表获取对应的图片
    public List<Image> getImageByToHulberId(String toHulberId) {
        return imageRepository.findAllByToHulberId(toHulberId);
    }

    //获取所有图片
    public List<Image> getAllImage(){
        return imageRepository.findAll();
    }
}
